package com.ljp.swagger.controller;

import com.ljp.swagger.entity.UserEntity;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: LJP
 * @Classname UserController
 * @Date: 2020-02-26 07:50
 * @Description: 测试Swagger API文档
 */
@RestController
@RequestMapping("/user1")
public class UserController {


    @ApiOperation(value = "接口标题：测试hello带参数方法", notes = "接口描述：hello带参数方法,给参数加上注解生成到API文档中")
    @GetMapping("/hello")
    public String hello(@ApiParam("方法参数") String param){
        return "hello" + param;
    }


    @ApiOperation(value = "接口标题：测试返回实体类的user方法", notes = "接口描述：只要该注解修饰的方法返回实体类,就会把该实体类中定义API接口中描述的信息生成到API文档中")
    @PostMapping("/user")
    public UserEntity userEntity(){
        return new UserEntity("smallRubbish", "123");
    }
}
